/************************************************************
*	Check WsForm
*************************************************************/
function checkZgjysForm(thisform)
{
	if(!checkMaxLength(thisform.fwbh,6,
	"\u53D1\u6587\u7F16\u53F7\u957F\u5EA6\u4E0D\u5F97\u8D85\u8FC76\u4F4D\uFF08\u6C49\u5B57\u53602\u4F4D\uFF09\u3002")) 
		return false;
			
	var fjfs = thisform.fjfs.value;
	for(i=0;i<fjfs.length;i++)
	{
		if(fjfs.charAt(i)<'0'||fjfs.charAt(i)>'9')
		{
			//
			alert("\u6570\u636E\u683C\u5F0F\u9519\u8BEF\uFF1A\n\u9644\u4EF6\u4EFD\u6570\u5FC5\u987B\u4E3A\u6574\u6570\u3002");
			thisform.fjfs.select();
			return false;
		}
	}
	if(fjfs.length>4)
	{
		alert("\u9644\u4EF6\u4EFD\u6570\u6570\u503C\u8FC7\u5927\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\uFF01");
		thisform.fjfs.select();
		return false;
	}
	
	if(!checkGtToday(thisform.fkrq.value))
	{
		if(confirm("\u63D0\u793A\uFF1A\n          \u5F55\u5165\u7684\u53CD\u9988\u65E5\u671F\u671F\u9650\u6BD4\u4ECA\u5929\u8981\u65E9\uFF0C\u4F1A\u9020\u6210\u5BF9\u65B9\u903E\u671F\u53CD\u9988\uFF0C\n\u9700\u8981\u4FEE\u6539\u53CD\u9988\u65E5\u671F\u671F\u9650\u5417\uFF1F"))
		{
			thisform.fkrq.select();
			return false;
		}
	}
	//if(confirm("\u786E\u5B9A\u8981\u63D0\u4EA4\u5417\uFF1F"))
		return true;	
	//else
	//	return false;
}

function checkJcjysForm(thisform)
{
	//jcjysForm
	if(!checkMaxLength(thisform.fwbh,6,
	"\u53D1\u6587\u7F16\u53F7\u957F\u5EA6\u4E0D\u5F97\u8D85\u8FC76\u4F4D\uFF08\u6C49\u5B57\u53602\u4F4D\uFF09\u3002")) 
		return false;
		
	if(!checkGtToday(thisform.fkrq.value))
	{
		if(confirm("\u63D0\u793A\uFF1A\n          \u5F55\u5165\u7684\u53CD\u9988\u65E5\u671F\u671F\u9650\u6BD4\u4ECA\u5929\u8981\u65E9\uFF0C\u4F1A\u9020\u6210\u5BF9\u65B9\u903E\u671F\u53CD\u9988\uFF0C\n\u9700\u8981\u4FEE\u6539\u53CD\u9988\u65E5\u671F\u671F\u9650\u5417\uFF1F"))
		{
			thisform.fkrq.select();
			return false;
		}
	}
	//ccqjQ ccqjZ
	if(thisform.ccqjQ.value!=""&&thisform.ccqjZ.value!="")
	{
		if(!checkDate(thisform.ccqjQ.value,thisform.ccqjZ.value,
			"\u67E5\u5904\u671F\u95F4  \u5F00\u59CB\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u7ED3\u675F\u65E5\u671F"))
		{
			thisform.ccqjZ.select();
			return false;
		}
	}
}

function checkNumber(item)
{
	var num = item.value;
	for(i=0;i<num.length;i++)
	{
		if(num.charAt(i)!='.'&&(num.charAt(i)<'0'||num.charAt(i)>'9'))
		{
			alert("\u6570\u503C\u8F93\u5165\u9519\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\uFF01");
			item.select();
			return false;
		}
	}
}
/****************************************************
*	Check QueryForm
*****************************************************/
function checkQueryZgjys()
{
	if(!checkTree("fcdw","\u8BF7\u9009\u62E9\u5EFA\u8BAE\u4E66\u53D1\u51FA\u5355\u4F4D")) 
		return false;
	if(!checkTree("jsdw","\u8BF7\u9009\u62E9\u5EFA\u8BAE\u4E66\u63A5\u6536\u5355\u4F4D")) 
		return false;
	//cwsj
	if(wsSearchForm.cwsj_pre.value!=""&&wsSearchForm.cwsj_post.value!="")
	{
		if(!checkDate(wsSearchForm.cwsj_pre.value,wsSearchForm.cwsj_post.value,
			"\u6210\u6587\u65F6\u95F4  \u5F00\u59CB\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u7ED3\u675F\u65E5\u671F"))
			return false;
	}
	
	//czrq
	if(wsSearchForm.czrq_pre.value!=""&&wsSearchForm.czrq_post.value!="")
	{
		if(!checkDate(wsSearchForm.czrq_pre.value,wsSearchForm.czrq_post.value,
			"\u64CD\u4F5C\u65E5\u671F  \u5F00\u59CB\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u7ED3\u675F\u65E5\u671F"))
			return false;
	}
	return true;
}

function checkQueryJcjys()
{
	if(!checkTree("fcdw","\u8BF7\u9009\u62E9\u5EFA\u8BAE\u4E66\u53D1\u51FA\u5355\u4F4D")) 
		return false;
	if(!checkTree("jsdw","\u8BF7\u9009\u62E9\u5EFA\u8BAE\u4E66\u63A5\u6536\u5355\u4F4D")) 
		return false;
	//czrq
	if(wsSearchForm.czrq_q.value!=""&&wsSearchForm.czrq_z.value!="")
	{
		if(!checkDate(wsSearchForm.czrq_q.value,wsSearchForm.czrq_z.value,
			"\u5EFA\u8BAE\u4E66\u5F55\u5165\u65F6\u95F4  \u5F00\u59CB\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u7ED3\u675F\u65E5\u671F"))
			return false;
	}
	
	//sprq_ws
	if(wsSearchForm.sprq_ws_q.value!=""&&wsSearchForm.sprq_ws_z.value!="")
	{
		if(!checkDate(wsSearchForm.sprq_ws_q.value,wsSearchForm.sprq_ws_z.value,
			"\u5EFA\u8BAE\u4E66\u5BA1\u6279\u65F6\u95F4  \u5F00\u59CB\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u7ED3\u675F\u65E5\u671F"))
			return false;
	}
	return true;
}

function checkQueryJcmx()
{
	if(!checkTree("fcdw","\u8BF7\u9009\u62E9\u5EFA\u8BAE\u4E66\u53D1\u51FA\u5355\u4F4D")) 
		return false;
	if(!checkTree("jsdw","\u8BF7\u9009\u62E9\u5EFA\u8BAE\u4E66\u63A5\u6536\u5355\u4F4D")) 
		return false;
		
	//sprq_ws
	if(wsSearchForm.sprq_ws_q.value!=""&&wsSearchForm.sprq_ws_z.value!="")
	{
		if(!checkDate(wsSearchForm.sprq_ws_q.value,wsSearchForm.sprq_ws_z.value,
			"\u5EFA\u8BAE\u4E66\u5BA1\u6279\u65F6\u95F4  \u5F00\u59CB\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u7ED3\u675F\u65E5\u671F"))
			return false;
	}
	
}
/************************************************************
*	Check WsForm
*************************************************************/


function numberFormat(s)
{
	res = Number(s.value).toFixed(2)
	return res;
}
		

function doBack(flag)
{
	if(window.opener==null) window.history.back(-1);
		
	else
	{
		if(flag) window.opener.location.reload();//success to reload
		window.close();
	}
}

function checkRequire(one,two,errorMessage)
{
	if(one.value!=""&&two.value=="")
	{	
		alert(errorMessage);
		return false;
	}
	if(one.value==""&&two.value!="")
	{
		alert(errorMessage);
		return false;
	}
	return true;
}

function checkDate(DateOne, DateTwo, errorMessage) {
    var OneMonth = DateOne.substring(5, DateOne.lastIndexOf("-"));
    var OneDay = DateOne.substring(DateOne.length, DateOne.lastIndexOf("-") + 1);
    var OneYear = DateOne.substring(0, DateOne.indexOf("-"));
    var TwoMonth = DateTwo.substring(5, DateTwo.lastIndexOf("-"));
    var TwoDay = DateTwo.substring(DateTwo.length, DateTwo.lastIndexOf("-") + 1);
    var TwoYear = DateTwo.substring(0, DateTwo.indexOf("-"));
    if (Date.parse(OneMonth + "/" + OneDay + "/" + OneYear) > Date.parse(TwoMonth + "/" + TwoDay + "/" + TwoYear)) {
        alert(errorMessage);
        return false;
    }
    return true;
}

function checkTree(dw,message)
{
	var flag=0;
	for(i=0;i<document.getElementsByName(dw).length;i++)
	{
		if(document.getElementsByName(dw)[i].checked == true)
		{
			flag=1;
			break;
		}
	}	
	if(flag==0)
	{
		alert(message);
		return false;
	}
	return true;
}

function checkGtToday(DateOne) {
	var now = new Date();
	var OneMonth = DateOne.substring(5, DateOne.lastIndexOf("-"));
    var OneDay = DateOne.substring(DateOne.length, DateOne.lastIndexOf("-") + 1);
    var OneYear = DateOne.substring(0, DateOne.indexOf("-"));
    if (Date.parse(OneMonth + "/" + OneDay + "/" + OneYear) < now.getTime()) 
        return false;
    else
    	return true;
}

function checkMaxLength(item,MaxLength,message)
{
	var len = item.value.replace(/[^\x00-\xFF]/g,'**').length;
	if(len>MaxLength)
	{
		alert(message);
		item.select();
		return false;
	}
	else 
		return true;
	
}